#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	int n;scanf("%d",&n);
	int a=0,b=1,c=a+b;
	while(c<n){
		a=b;
		b=c;
		c=a+b;
	}
	int ans=abs(c-n)<abs(b-n)?c:b;
	printf("%d\n", ans);
	return 0;
}